#include "connectmanager.h"

template<typename  T>
int cmplink(T a,T b)
{
	if(a == b)
	{
		return 1;
	}
	else if(a > b)
	{
		return 0;
	}
	else
	{
		return 2;
	}
}

linkinfo::linkinfo(const std::string& dstip, const unsigned int dstport, const std::string& localip, const unsigned int localport, const LINKTYPE lktype)
    : dest_ip(dstip)
    , dest_port(dstport)
    , local_ip(localip)
    , local_port(localport)
    , linktype(lktype)
{
}

linkinfo::~linkinfo()
{
}

bool linkinfo::operator<(const linkinfo& cmp)
{
	bool flags = false;
	int cmpres = 0;
	for(int i = 0; i < 5;++i)
	{

		if(i == 0)
		{
			cmpres = cmplink(dest_ip, cmp.dest_ip);
		}
		else if(i == 1)
		{
			cmpres = cmplink(dest_port, cmp.dest_port);
		}
		else if(i == 2)
		{
			cmpres = cmplink(local_ip, cmp.local_ip);
		}
		else if(i == 3)
		{
			cmpres = cmplink(local_port, cmp.local_port);
		}
		else
		{
			cmpres = cmplink(linktype, cmp.linktype);
		}
		if(cmpres == 0)
		{
			return false;
		}
		else if(cmpres == 2)
		{
			return true;
		}
	}
	return false;
}

int main()
{
}
